$(function () {
    $('.am-header-title').text('登录');

    function showalert(txt) {
        $("#modal-alert").find(".am-modal-bd").text(txt)
            .end()
            .modal("open");
    }

    var Latitude = "0.000000";
    var Longitude = "0.000000";


    $("#loginsubmit").click(function () {


        if (navigator.geolocation) {

            navigator.geolocation.getCurrentPosition(function (position) {
                Latitude = position.coords.latitude;
                Longitude = position.coords.longitude;
            });
        }


        var UI = {
            accountV: $('#account').val(),
            passwordV: $('#password').val()
        };
        if (UI.accountV == '') {
            showalert("请输入账号");
            return false;
        }
        if (UI.passwordV == '') {
            showalert("请输入密码");
            return false;
        }

        var url = "/h5/doLogin";
        $.ajax({
            type: 'POST',
            dataType: 'json',
            url: url,
            data: {
                account: $("#account").val(),
                password: $('#password').val(),
                xpoint: Latitude,
                ypoint: Longitude

            },
            success: function (res) {

                if (res.code == '000000') {
                    localStorage.setItem("user", JSON.stringify(res.user));
                    $("#loginsubmit").button("loading");
                    window.location.href = "../index.jsp";

                } else {
                    showalert(res.msg);
                }

            },
            error: function (res) {

            }
        });


    });


    $("#forgetPassword").click(function () {
        window.location.href = "./forget-password.jsp"

    })

});

